package tests;

import ar.edu.itba.pod.printer.Document;
import ar.edu.itba.pod.printer.PrinterDispatcher;
import ar.edu.itba.pod.printer.impl.SimpleAsyncPrinterDispatcher;

public class SimpleAsynTest1 {
	
	
	public static void main(String[] args) {
		
		final int PRUBES = 10;
		long time=0;
		
		System.out.println( "ej 3.2");
		
		for(int i=0; i<PRUBES;i++){
			time+=fiftyRequest();
			System.out.println("prueba terminada");
		}
		System.out.println( "Tiempo Promedio:" +  time/PRUBES );
	}
	
	public static long fiftyRequest(){
		final int PRINT_REQUEST = 50;
		final int PAGES = 5;
		final String DOC_NAME = "name";
		
		long start= System.currentTimeMillis();
		PrinterDispatcher dispatcher = new SimpleAsyncPrinterDispatcher();
		
		for(int r=0;r < PRINT_REQUEST; r++){
			Document document=new Document(PAGES, false, DOC_NAME);
			dispatcher.printDocument(document);
		}
		dispatcher.finishPrintRequests();
		return System.currentTimeMillis()-start;
		
	}

}
